package com.ruoyi.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class OrderConstants {
    /**
     * 订单状态枚举
     */
    @AllArgsConstructor
    @Getter
    public enum OrderStatusEnum {
        PRE_PAY(0, "待付款", false),
        PRE_SEND(1, "待发货", false),
        PRE_RECEIVE(2, "待收货", false),
        COMPLETE(3, "已完成", true),
        CANCEL(10, "已取消", true),
        NULL(-1, "全部", false),
        ;

        private int value;
        private String valueDesc;
        private boolean canDelete;

        public static OrderStatusEnum match(int value) {
            for (OrderStatusEnum one : OrderStatusEnum.values()) {
                if (one.getValue() == value) {
                    return one;
                }
            }
            return OrderStatusEnum.NULL;
        }
    }

    /**
     * 积分商城订单状态枚举
     */
    @AllArgsConstructor
    @Getter
    public enum CreditOrderStatusEnum {
        UN_USE(0, "未核销", false),
        USE(1, "已核销", false),
        NULL(-1, "全部", false);

        private int value;
        private String desc;
        private boolean canDelete;

        public static OrderStatusEnum match(int value) {
            for (OrderStatusEnum one : OrderStatusEnum.values()) {
                if (one.getValue() == value) {
                    return one;
                }
            }
            return OrderStatusEnum.NULL;
        }
    }

    /**
     * 支付状态枚举
     */
    @AllArgsConstructor
    @Getter
    public enum OrderPayStatusEnum {

        //未支付
        PRE_PAY(0),
        //已支付
        COMPLETE(1),
        //待退款
        PRE_REFUND(2),
        //退款中
        REFUNDING(3),
        //部分退款成功
        REFUND_PART_SUCCESS(4),
        //全额退款成功
        REFUND_SUCCESS(5),
        //支付超时
        TIMEOUT(9),
        //退款失败
        REFUND_FAIL(11),
        //不存在
        NULL(-1),
        ;

        private int value;

        public static OrderPayStatusEnum match(int value) {
            for (OrderPayStatusEnum one : OrderPayStatusEnum.values()) {
                if (one.getValue() == value) {
                    return one;
                }
            }
            return OrderPayStatusEnum.NULL;
        }
    }

    /**
     * 交易方式枚举
     */
    @AllArgsConstructor
    @Getter
    public enum OrderPayWayEnum {

        //	余额支付
        BALANCE_PAY(0),
        //	支付宝
        AILI_PAY(1),
        //	微信
        WX_PAY(2),
        //	线下转账
        OFFLINE_PAY(3),
        //未知
        NULL(-1),
        ;
        private int value;

        public static OrderPayWayEnum match(int value) {
            for (OrderPayWayEnum one : OrderPayWayEnum.values()) {
                if (one.getValue() == value) {
                    return one;
                }
            }
            return OrderPayWayEnum.NULL;
        }
    }

    /**
     * 退款状态枚举
     */
    @AllArgsConstructor
    @Getter
    public enum RefundStatusEnum {
        //待审核
        REVIEW(0, false),
        //待退款
        PRE_REFUND(1, false),
        //退款中
        REFUNDING(2, true),
        //退款成功
        COMPLETE(3, true),
        //已拒绝
        REJECT(10, true),
        //退款失败
        FAIL(11, true),
        //未知状态
        NULL(-1, false),
        ;

        private int value;
        private boolean canDelete;

        public static RefundStatusEnum match(int value) {
            for (RefundStatusEnum one : RefundStatusEnum.values()) {
                if (one.getValue() == value) {
                    return one;
                }
            }
            return RefundStatusEnum.NULL;
        }
    }

    /**
     * 订单号前缀枚举
     */
    @AllArgsConstructor
    @Getter
    public enum SnPrefix {
        PETROL("O"),//用户加油订单
        CANCEL_USER("X"),//用户主动取消退款（微信支付后台可查）
        CANCEL_SHOP("XB"),//商家主动取消退款（微信支付后台可查）
        PAY_MEMBER("PM"),//会员付款（微信支付后台可查，余额支付不可查，包含充值和下货）
        PAY_BACK("PB"),//后台付款
        CREDIT_PRODUCT_MEMBER("CP"),//会员兑换积分商城商品
        CHARGE_MEMBER("C"),//会员充值
        BALANCE_MEMBER("CB"),//会员余额变动
        CREDIT_MEMBER("CC"),//会员积分变动
        CREDIT_MEMBER_BACK("BC"),//会员积分变动
        BALANCE_MEMBER_BACK("BB"),//会员余额变动
        BUY_SHOP("B"),//店铺订单
        CANCEL_BACK("XX"),//店铺余额变动
        ;
        private String value;
    }

    /**
     * 退款订单类型枚举
     */
    @AllArgsConstructor
    @Getter
    public enum RefundOrderTypeEnum {

        //会员充值订单退款
        MEMBER_RECHARGE_ORDER(0),
        //加油订单退款
        PETROL_ORDER(1),
        ;
        private int value;
    }

}


